# -- coding: utf-8 --
#上面这个解决的是中文注释报错问题

def m1():
    from random import choice
    x=choice(["hello,world",[1,2,'3','e']])
    print x

def m2():
    from operator import add
    # addnum=add(1,'234')
    # print addnum

def m3():
    foo = Person(None,None)
    foo.setName("a")
    foo.setAge(5)
    foo.greet()
    foo.usePrivateMethod()
    return foo
    # foo.__privateMethod() 使用私有化方法报错  Person instance has no attribute '__privateMethod'
    # foo._Person_privateMethod()
    # Person._Person_privateMethod()

def m4(name,age):
    p=Person(name,age)
    return p

class Person:
    def setName(self,name):
        self.name=name

    def __init__(self,name,age):
        self.name=name
        self.age=age

    def setAge(self,age):
        self.age=age
    def greet(self):
        print "name",self.name,",age:",self.age
    def __privateMethod(self):
        print "i am private method"
    def usePrivateMethod(self):
        self.__privateMethod()
        print "use private method"




if __name__ == "__main__":
    # m1()
    # m2()
    person1=m3()
    print person1.name,person1.age
    person2=m4('tom',34)
    person3=m4(None,None)
    print person2.name,person2.age
    print person3.name,person3.age
    if person3.age > person2.age:
        print person3.name+"大于"+person2.name
    else:
        print person3.name,"年龄小于",person2.name
    person3.usePrivateMethod()


    # print person.name
